package com.novax.ex.activity.provider.service;

import com.novax.ex.activity.infrastructure.entity.TaskRule;
import com.novax.ex.activity.infrastructure.mapper.TaskRuleMapper;
import com.novax.ex.common.base.BaseMapper;
import com.novax.ex.common.base.BaseService;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * hsylient
 * 新手引导项目-新手引导介绍内容service
 */
@Service
public class TaskRuleService extends BaseService {

    @Resource
    private TaskRuleMapper taskRuleMapper;

    @Override
    protected BaseMapper getBaseMapper() {
        return taskRuleMapper;
    }

    /**
     * 查询后管配置的活动规则 英语是默认配置的 有对用的language按照language来查询 没有的话按照英语来查询
     *
     * @param language 语言
     * @return
     */
    public String getTaskRule(String language) {
        String ruleContent = taskRuleMapper.selectContentByLanguage(language);
        return Optional.ofNullable(ruleContent).orElse("");
    }

    /**
     * @Description: 查询规则所有多语言配置
     * @Author: ChenXi
     * @Date:  2023/6/25 17:27
     * @param
     * @return: java.lang.Object
     **/
    public List<TaskRule> queryAll() {
        return taskRuleMapper.queryAll();
    }

}
